package com.dg.gaming.api.common.msg;

import nanoxml.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2009</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class MsgNoMove extends MsgTableMessage {
    public static final String XML_ATT_NOMOVE = "nomove";
    private static final String XML_ATT_DELEY = "deley";
    private static final String XML_ATT_LOSE = "lose";
    private int deley;
    private boolean lose;
    public MsgNoMove(int deley, boolean lose) {
        super();
        this.deley = deley;
        this.lose = lose;
    }

    public MsgNoMove(XMLElement message) {
        super(message);
        deley = message.getIntAttribute(XML_ATT_DELEY);
        lose = message.getIntAttribute(XML_ATT_DELEY) == 1;
    }

    /**
     * This method flattens an ITransmittable object into a XMLElement which
     * can be transmitted.
     *
     * @return XML version of the state of an object which can be
     *   constructed again.
     * @todo Implement this com.dg.gaming.api.common.msg.ITransmittable
     *   method
     */
    public XMLElement flatten() {
        XMLElement ele = super.flatten(XML_ATT_NOMOVE);
        ele.setIntAttribute(XML_ATT_DELEY, deley);
        ele.setIntAttribute(XML_ATT_LOSE, lose ? 1 : 2);
        return ele;
    }

    public int getDeley() {
        return deley;
    }

    public boolean isLose() {
        return lose;
    }
}
